package com.share.hope.controller;

import com.share.hope.entity.UserInfo;
import com.share.hope.entity.result.R;
import com.share.hope.service.UserInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/share/hope/user")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "用户信息管理接口")
@CrossOrigin
public class UserInfoController {

    private final UserInfoService userInfoService;

    @PostMapping("/register")
    @Operation(summary = "注册")
    public R<String> register(@RequestBody UserInfo userInfo){
        log.info("[UserInfoController][register] input userInfo is: {}", userInfo);
        return userInfoService.register(userInfo);
    }

    @PostMapping("/login")
    @Operation(summary = "登录")
    public R<UserInfo> login(@RequestBody UserInfo userInfo) {
        log.info("[UserInfoController][login] input userInfo is: {}", userInfo);
        return userInfoService.login(userInfo);
    }

    @PostMapping("/update_password")
    @Operation(summary = "修改密码")
    public R<String> updatePassword(@RequestBody UserInfo userInfo) {
        log.info("[UserInfoController][updatePassword] input userInfo is: {}", userInfo);
        return userInfoService.updatePassword(userInfo);
    }

}
